package leetcode.lt100;

class Solution_74 {

	public static void main(String[] args) {

	}

	public boolean searchMatrix(int[][] matrix, int target) {

		int m = matrix[0].length;
		int n = matrix.length;

		int x = -1;

		for (int i = 0; i < n; i++) {
			if (matrix[i][0] <= target && matrix[i][m - 1] >= target) {
				x = i;
				break;
			}
		}

		if (x == -1)
			return false;

		for (int i : matrix[x]) {
			if (i == target)
				return true;
		}

		return false;
	}

}